﻿using System;

namespace ProgrammingPatterns.DesignPatterns.Creational.Prototype
{
    // Prototype Pattern
    // Serializable is used for the deep copy option
    [Serializable]
    public class Country : Prototype<Country>
    {
        #region [ properties ]
        public string Name { get; set; }
        public string Capital { get; set; }
        public DeeperData Language { get; set; }
        #endregion

        #region [ .ctor ]
        /// <summary>
        /// Initializes a new instance of the <see cref="Country"/> class.
        /// </summary>
        /// <param name="countryName">Name of the country.</param>
        /// <param name="countryCapital">The country capital.</param>
        /// <param name="countryLanguage">The country language.</param>
        public Country(string countryName, string countryCapital, string countryLanguage)
        {
            Name = countryName;
            Capital = countryCapital;
            Language = new DeeperData(countryLanguage);
        }
        #endregion

        #region [ methods ]
        public override string ToString()
        {
            return string.Format("{0}-{1}-{2}", Name, Capital, Language);
        }
        #endregion
    }

    [Serializable]
    // Helper class used to create a second level data structure
    public class DeeperData
    {
        public string Data { get; set; }

        public DeeperData(string s)
        {
            Data = s;
        }
        public override string ToString()
        {
            return Data;
        }
    }
}